-- FETCH_COMPONENT_SHOP_GOODS

-- 抽取原罪小屋的商品
-- @param user 玩家对象
return function(user)
    -- 3件固定为：爆破元件×3、生化元件×3、冶金元件×3
    -- 第4件：随机木偶零件×1（40%）、随机普通元件×3（40%）、古代元件×2（20%）
    local ret = {{ ["goodsId"] = 1401, }, { ["goodsId"] = 1402, }, { ["goodsId"] = 1403, }};


    -- 先抽取一种木偶零件
    local puppetId = 0;
    local puppetRatio = 600;
    local arr = { 1405, 1406, 1407, 1408, 1409 };

    -- 如果都出现过，或者在迷宫小关，木偶零件的权重置0
    for index = #arr, 1,-1 do
        if DungeonShopM.getGoodsTimes(arr[index]) > 0 then
            table.remove(arr, index);
        end
    end

    -- 迷宫小关不出现
    local rand;
    local dungeonId = DungeonM.getDungeonId();
    if #arr == 0 or type(dungeonId) == "number" and dungeonId > 0 and DungeonAreaM.query(dungeonId, "type") == "child" then
        puppetRatio = 0;
    else
        rand = DungeonM.getRandSeed("FETCH_COMPONENT_SHOP_GOODS");
        puppetId = FormulaM.invoke("FETCH_BY_RAND", arr, rand);
    end

    -- 抽取第4个
    local arr = {
        {["class_id"] = 1401, ["ratio"] = 200, },   -- 爆破元件
        {["class_id"] = 1402, ["ratio"] = 200, },   -- 生化元件
        {["class_id"] = 1403, ["ratio"] = 200, },   -- 冶金元件
        {["class_id"] = 1404, ["ratio"] = 300, },   -- 古代元件
        {["class_id"] = puppetId, ["ratio"] = puppetRatio, }, -- 木偶零件
    };

    rand = DungeonM.getRandSeed("FETCH_COMPONENT_SHOP_GOODS");
    local classId = fetchElemBySeed(arr, rand)["class_id"];

    table.insert(ret, { ["goodsId"] = classId, });

    return ret;
end